<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var arr = [6, 7, 8, 1, 2, 3];
        arr.sort();
        console.log(arr);

        var arr2 = [2342, 34, 231, 12, 56];

        console.log(Array.prototype);

        //通过向构造器的原型中添加方法可以扩展类型
        Array.prototype.sum = function () {
            var result = 0;
            for (var i = 0; i < this.length; i++) {
                result += this[i];
            }
            return result;
        }

        //覆盖
        // Array.prototype={
        //     sum:function(){

        //     }
        // };

        console.log(arr.sum());
        console.log(arr2.sum());
        console.log([67,67,88,5,4].sum());
    </script>
</body>

</html>